﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace Itop.KSRY {
    public partial class UCksInfo : XtraUserControl {
        public UCksInfo() {
            InitializeComponent();       
        }
        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
            init();
        }
        private void init() {
            foreach (var font in FontFamily.Families) {
                comboBoxEdit1.Properties.Items.Add(font.Name);
            }
            memoEdit1.EditValue = Properties.Settings.Default.ksInfo;
            comboBoxEdit1.SelectedItem = Properties.Settings.Default.fontName;
            spinEdit1.EditValue = Properties.Settings.Default.fontSize;
            comboBoxEdit1.SelectedIndexChanged += new EventHandler(comboBoxEdit1_SelectedIndexChanged);
            spinEdit1.ValueChanged += new EventHandler(spinEdit1_ValueChanged);
            memoEdit1.EditValueChanging += new DevExpress.XtraEditors.Controls.ChangingEventHandler(memoEdit1_EditValueChanging);
        }

        void memoEdit1_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) {
            Properties.Settings.Default.ksInfo = e.NewValue.ToString();
        }

        void spinEdit1_ValueChanged(object sender, EventArgs e) {
            Properties.Settings.Default.fontSize =Convert.ToUInt16(spinEdit1.EditValue);
        }

        void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) {
            Properties.Settings.Default.fontName = comboBoxEdit1.SelectedItem.ToString();
        }
        public void Save() {
            Properties.Settings.Default.ksInfoFont = new Font(Properties.Settings.Default.fontName, Properties.Settings.Default.fontSize, FontStyle.Bold);
            Properties.Settings.Default.Save();
        }
    }
}
